﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Xml;
using System.Configuration;

namespace Lilium.Configuration
{
	/// <summary>
	/// Аргументы события разрешения полиморфного элемента конфигурации.
	/// </summary>
	public sealed class ResolveUnrecognizedElementEventArgs: EventArgs
	{
		public ResolveUnrecognizedElementEventArgs(string elementName, XmlReader reader)
		{
			if (string.IsNullOrEmpty(elementName))
				throw new ArgumentNullOrEmptyException("elementName");
			if (reader == null)
				throw new ArgumentNullException("reader");

			m_Reader = reader;
			m_ElementName = elementName;
		}

		#region public XmlReader Reader

		private readonly XmlReader m_Reader;

		public XmlReader Reader
		{
			[DebuggerNonUserCodeAttribute]
			get
			{
				return m_Reader;
			}
		}

		#endregion

		#region public string ElementName

		private readonly string m_ElementName;

		/// <summary>
		/// Имя элемента.
		/// </summary>
		public string ElementName
		{
			[DebuggerNonUserCodeAttribute]
			get
			{
				return m_ElementName;
			}
		}

		#endregion

		#region public bool IsResolved

		/// <summary>
		/// true если элемент определен, иначе false.
		/// </summary>
		public bool IsResolved
		{
			[DebuggerNonUserCodeAttribute]
			get
			{
				return ResolvedElement != null;
			}
		}

		#endregion

		#region public ConfigurationElement ResolvedElement

		private ConfigurationElement m_ResolvedElement;

		/// <summary>
		/// Определенный конфигурационный элемент.
		/// </summary>
		public ConfigurationElement ResolvedElement
		{
			[DebuggerNonUserCodeAttribute]
			get
			{
				return m_ResolvedElement;
			}
			[DebuggerNonUserCodeAttribute]
			set
			{
				m_ResolvedElement = value;
			}
		}

		#endregion
	}
}
